public class Solution {
    public static void main(String[] args) {
        int year = 2016;
        int month = 3;
        int day = 30;
        int sum = 0;

        int leap = 0;
        if (year % 400 == 0 || year % 4 == 0 && year % 100 == 0) {
            leap++;
        }

        int[] days = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
        if (month <= 12 && month > 0 && day > 0 && day < 31&&year>0 &&month!=2) {
            sum = days[month - 1];
            sum += day;
            sum += leap;
        } else {
            sum = -1;
        }

        System.out.println(sum);


    }
}



